package com.comac.print.component.app.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @Description 转换字符串工具类
 * @Author lihao
 * @Date 2021/12/23 18:06
 */
public class ToStringUtil {

    /**
     * 将 Exception 转化为 String
     */
    public static String getExceptionToString(Throwable e) {
        if (e == null){
            return "";
        }
        StringWriter stringWriter = new StringWriter();
        e.printStackTrace(new PrintWriter(stringWriter));
        return stringWriter.toString();
    }
}
